#ifndef GUI_H
#define GUI_H

#include <QWidget>
#include <QPushButton>
#include <QLineEdit>
#include <QComboBox>
#include <QTextEdit>
#include <QLabel>
#include <QFileDialog>
#include <QMessageBox>
#include <QFileInfo>
#include <QJsonObject> // For JSON operations (if chosen later)
#include <QJsonDocument> // For JSON operations (if chosen later)

// 包含签名管理器的头文件，假设这些路径在你的项目中是正确的
#include "signature_manager/RSA.h"
#include "signature_manager/DSA.h"
#include "signature_manager/Rabin.h"
#include "signature_manager/ECDSA.h"
#include "signature_manager/EdDSA.h"
#include "signature_manager/Hash.h"
#include "signature_manager/signature_manager.h"
#include "signature_manager/data_conversion.h"
#include "signature_manager/GMPInt.h"

class SignatureGUI : public QWidget {
    Q_OBJECT

public:
    explicit SignatureGUI(QWidget *parent = nullptr);
    ~SignatureGUI();

private slots:
    void browseInputFile();
    void onAlgorithmSelected(int index);
    void signFile();
    void verifyFile();

    // 批量导入/导出
    void exportAllData();
    void importAllData();


private:
    void setupUI();
    SignatureManager_base* createSignatureManager(const std::string& algorithm, int keyLength, const std::string& curveName);
    void updateKeyCurveOptions(const QString& algorithm); // Added this function

    // UI Elements
    QLineEdit *inputFileEdit;
    QComboBox *algorithmCombo;
    QLineEdit *keyLengthEdit;
    QComboBox *curveNameCombo; // For ECDSA/EdDSA curves

    QTextEdit *publicKeyText;
    QTextEdit *publicParametersText;
    QTextEdit *signatureText;
    QTextEdit *resultText; // To display success/failure

    QPushButton *signButton;
    QPushButton *verifyButton;

    // File operation buttons (individual)
    QPushButton *browseInputButton;

    // 批量操作按钮
    QPushButton *exportAllButton;
    QPushButton *importAllButton;

    SignatureManager_base* currentSignatureManager = nullptr; // 用于存储当前活跃的签名管理器实例
};

#endif // GUI_H